Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ExtremePowers · Nov 05, 2014 at 11:27 PM · threadingqueue

Queue and Threading

How would I go about making a queue, I have tried a couple of things but never got it working. So do you have any good points to start on this? :) I am trying to queueing something on another thread and then when it is done it executes some script on the mainThread, and then goes on to the next in the line.

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlwaysSunny · Nov 06, 2014 at 12:21 AM 0
Share

This is a general program$$anonymous$$g question. The Queue generic collection in System.Collections.Generic is perfectly suited for this - usually.

avatar image devluz · Nov 06, 2014 at 01:03 AM 1
Share

What exactly do you want to put in this queue? Using multiple threads can cause plenty of problems.

avatar image Kiwasi · Nov 06, 2014 at 02:32 AM 0
Share

The Task class is a reasonable way to do it. There are other ways. Due to Unity's avoidance on threads you won't find too many people here who do heavy multi threading.

avatar image ExtremePowers · Nov 06, 2014 at 07:47 AM 0
Share

How would I assign a type to my queue (in JS) I have tried like this, but without any luck:

 class info {
     var Test : int;
     var Test1 : int;
 }
 
 var queue : Queue.<info>;
 function Start() {
     queue = new Queue.<info>();
 }

but when trying to call it like this:

 Debug.Log(queue.Peek.Test);

it gives me this error:

  BCE0019: 'Test' is not a member of 'function(): info'.

The type of the queue.Peek is:

CompilerGenerated.PT_Update$callable0$210_57

avatar image Bunny83 · Nov 06, 2014 at 08:49 AM 0
Share

@ExtremePowers:
`Peek()` is a method, so you need to execute it by adding the brackets (the calling operator). However be sure you "queued" something or Peek will fail with an exception.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ExtremePowers · Nov 06, 2014 at 04:42 PM

Yeah, I know that unity isn't thread safe and so on, but I needed this feature to make the terrain generate without having that 1 second lag.. I don't use Random on the other thread, only on the main thread...

Wow, I feel really stupid now, I could just have used yield null; in the for loop each time z equals heightmapWidth, it would take some time for the terrain to be assigned, but that doesn't matter because the viewdistance isn't far enough to see the new generated terrain, while it is loading.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NetworkStream.GetStream() Coroutine 1 Answer

How to wait for callback in OnApplicationPause on android 0 Answers

How to clear UnityEditor memory? 0 Answers

Optimizing the generation of a procedural world - 50ms lag spike to 1 Answer

Unity Jobs Unknown Length of NativeArray 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges