اشتراک‌ها
دریافت Free SQL Server Download Pack

Here’s where you can download our First Responder Kit complete with:
- Our scripts: sp_Blitz, sp_BlitzCache, sp_BlitzIndex, sp_AskBrent, sp_BlitzRS, sp_BlitzTrace
- Our e-books: SQL Server Setup Guide, AlwaysOn Availability Groups Checklist, the DBA Training Plan, How to Develop Your DBA Career
- Our posters: Table Partitioning, Isolation Levels, Bandwidth Reference
- Our whitepapers: Factors of Cloud Success, Sizing Up Solid State Drives

دریافت Free SQL Server Download Pack
مطالب
آموزش زبان Rust - قسمت 9 - Memory Management در Rust از طریق Ownership
Rust، یک زبان برنامه نویسی است که به دلیل ایمنی و عملکرد مشهور است و مفهوم مالکیت را برای مدیریت مؤثر حافظه معرفی می‌کند. با رعایت مجموعه‌ای از قوانین زمان کامپایل، توسعه دهندگان Rust می‌توانند مشکلات مربوط به حافظه را کاهش داده و کد خود را بهینه کنند. این مقاله، قوانین مالکیت، مشکلاتی را که حل می‌کند و مثال‌های مختلفی را برای نشان دادن کاربرد آن، بررسی می‌کند.


قوانین مالکیت  

  • هر مقدار در Rust دارای یک متغیر مرتبط به نام مالک آن است.
  • در هر لحظه فقط یک مالک می‌تواند وجود داشته باشد.
  • وقتی مالک از scope خارج می‌شود، مقدار مرتبط حذف می‌شود.

مالکیت در Rust به جلوگیری از چندین مشکل مدیریت حافظه کمک می‌کند، از جمله:
 
  • Memory/resource leaks
  • Double free
  • Use after free

هر مقدار در Rust دارای یک متغیر مرتبط به نام مالک آن است

به مثال زیر توجه کنید:
let s1 = String::from("Rust");
در این مورد، s1 یک اشاره‌گر است که در stack قرار دارد؛ در حالیکه مقدار "Rust" در heap قرار می‌گیرد.

 طبق قوانین مالکیت:
 
  • s1 مالک داده‌های ذخیره شده‌ی در heap است.
  • هنگامیکه s1 از scope خارج شود، داده‌های آن نیز پاک می‌شوند.

تلاش برای ارجاع به s1 پس از خارج شدن آن از scope، منجر به خطا می‌شود؛ زیرا مقدار آن از heap حذف شده و دیگر وجود ندارد.


مالکیت منحصر به‌فرد (در هر لحظه فقط یک مالک می‌تواند وجود داشته باشد)  


اگر برای انتقال s1 به s2 از کد زیر استفاده کنید:
let s2 = s1;
Rust به‌طور خودکار مقدار s1 را به s2 منتقل می‌کند و اطمینان حاصل می‌کند که تنها یک مالک در یک زمان حضور دارد.


Cloning Values

اگر بخواهیم بجای جابجایی مقدار، آن را تولید/نمونه‌سازی مجدد (cloning) کنیم، می‌توانیم با فراخوانی متد ()clone این‌کار را انجام دهیم:
let s2 = s1.clone();
اکنون s2 کپی خود را از مقدار s1 دارد.


Primitive Data و Cloning

در Rust، داده‌های اولیه به‌طور کامل در stack ذخیره می‌شوند و به‌طور پیش فرض clone می‌شوند. نمونه سازی مجدد این انواع، ارزان است و تفاوتی بین clone و moving وجود ندارد.


پاس دادن Variables به Functions

ارسال یک متغیر به یک تابع، همان تأثیری را دارد که یک متغیر را به متغیر دیگری اختصاص می‌دهیم. به عنوان مثال، اگر s1 را به یک تابع ارسال کنیم، مالک جدید رشته p1 است ( p1 نام آرگومان تابع است). برای رفع هرگونه خطایی که ممکن است به این دلیل  ایجاد شود، می‌توانیم s1 را clone کرده و به تابع ارسال کنیم.
سیستم مالکیت Rust، یک راه قدرتمند را برای مدیریت حافظه‌ی در زمان کامپایل فراهم می‌کند و از مشکلات رایج مرتبط با حافظه جلوگیری می‌کند. با درک و پیروی از قوانین مالکیت، می‌توانید کد ایمن‌تر و کارآمدتری را در Rust بنویسید. 
اشتراک‌ها
ویدیوهای Visual Studio 2019 Launch Event

Learn about how Visual Studio 2019 is more productive, modern, and innovative, participate in live Q&As, and be the first to take the latest version for a spin. 

ویدیوهای Visual Studio 2019 Launch Event
اشتراک‌ها
چگونه Windows 11 را وادار به آپگرید کنیم؟
How to trigger Windows 11 to upgrade to latest version

In this video you'll learn a encourage to trigger a Windows 11 computer to upgrade to the latest publicly released version. Demonstrated here is the update for 24H2, but it will work for any version of Windows 11 in the future.
چگونه Windows 11 را وادار به آپگرید کنیم؟
اشتراک‌ها
کتاب رایگان R Programming Succinctly

The R programming language on its own is a powerful tool that can perform thousands of statistical tasks, but by writing programs in R, you gain tremendous power and flexibility to extend its base functionality. Senior Succinctly series author and editor James McCaffrey shows you how in R Programming Succinctly.

Table of Contents
  1. Getting Started
  2. Vectors and Functions
  3. Object-Oriented Programming
  4. Permutations and Combinations
  5. Advanced R Programming 
کتاب رایگان R Programming Succinctly
اشتراک‌ها
کتابخانه Hangfire

An easy way to perform background job processing in your .NET and .NET Core applications. No Windows Service or separate process required. CPU and I/O intensive, long-running and short-running jobs are supported. Backed by Redis, SQL Server, SQL Azure and MSMQ. 

PM> Install-Package Hangfire

After installation, update your existing OWIN Startup file with the following lines of code. If you do not have this class in your project or don't know what is it, please read the Quick start guide to learn about how to install Hangfire.

public void Configuration(IAppBuilder app)
{
    GlobalConfiguration.Configuration.UseSqlServerStorage("<connection string or its name>");
    
    app.UseHangfireServer();
    app.UseHangfireDashboard();
}  
کتابخانه Hangfire
اشتراک‌ها
سری 5 قسمتی کار با GitHub توسط Visual Studio

Using source control (1 of 5) | Getting started with GitHub

Welcome to the Getting started with GitHub series, where you will learn how to share your code from within Visual Studio by using Git and GitHub. In this episode, Robert shows how to add a solution to source control. 

سری 5 قسمتی کار با GitHub توسط Visual Studio
اشتراک‌ها
کتاب رایگان Java Succinctly Part 2

In this second e-book on Java, Christopher Rose takes readers through some of the more advanced features of the language. Java Succinctly Part 2explores powerful and practical features of Java, such as multithreading, building GUI applications, and 2-D graphics and game programming. Then learn techniques for using these mechanisms in coherent projects by building a calculator app and a simple game with the author.

Table of Contents
  1. Packages and Assert
  2. Reading and Writing to Files
  3. Polymorphism
  4. Anonymous Classes
  5. Multithreading
  6. Introduction to GUI Programming
  7. GUI Windows Builder
  8. 2-D Game Programming 
کتاب رایگان Java Succinctly Part 2